clear all;  clc;    close all;
cd 'SPECIFY YOUR PATH HERE'

table= readtable('./Data/KRW_Spot_2023_Logret.xlsx');

data_krw= table.fx_ret_log;
krw_log_ret= table.fx_ret_log;

T= length(krw_log_ret);
vol_past=NaN(T,1);

for i=30:T
    vol_past(i,1)= sqrt(252)* std(krw_log_ret(i-29:i,1))*100;
    
end

%plot(vol_past)

%%
figure('position', [0, 0, 900, 300]);
plot(table.Date(30:end), vol_past(30:end), 'LineWidth',2, 'color', [228/255 26/255 28/255]); 
grid on
grid minor
set(gca, "fontsize", 14)
ylabel('Annual Volatility (%)')

fig_name=strcat('./Output/Figure_1_KRW_vol_past.eps');
saveas(gcf, fig_name, 'epsc')
fig_name=strcat('./Output/Figure_1_KRW_vol_past.png');
saveas(gcf, fig_name)

